<template>
  <div>
    <div id="div" v-if="showDiv">这是一段文本</div>
    <button @click="getText">获取 div 内容</button>
  </div>  
</template>
<script>
export default {
  data(){
    return {
      showDiv: false,
    }
  },
  methods:{
    getText(){
      this.showDiv = true;
      this.$nextTick(()=>{
        var text = document.getElementById('div').innerHTML;
        console.log(text);
      })
    }
  },
}
</script>
<style scoped>

</style>


